<?php

use dmstr\helpers\Html;
use yii\helpers\Url;
use kartik\grid\GridView;
use yii\widgets\DetailView;
use yii\widgets\Pjax;
use dmstr\bootstrap\Tabs;

/**
* @var yii\web\View $this
* @var yiike\credit\models\Credit $model
*/
$copyParams = $model->attributes;

$this->title = '余额查看';
$this->params['breadcrumbs'][] = ['label' => $this->title, 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '用户 ' . (string)$model->user_id, 'url' => ['view', 'user_id' => $model->user_id]];
?>
<div class="giiant-crud credit-view">

    <!-- flash message -->
    <?php if (\Yii::$app->session->getFlash('deleteError') !== null) : ?>
        <span class="alert alert-info alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span></button>
            <?= \Yii::$app->session->getFlash('deleteError') ?>
        </span>
    <?php endif; ?>
    <div class="box box-info">
        <div class="box-header with-border">
            <h3 class="box-title">查看</h3>
        </div>
        <div class="nav-tabs-custom">
    <?php $this->beginBlock('yiike\credit\models\Credit'); ?>

    
    <?= DetailView::widget([
    'model' => $model,
    'attributes' => [
            'user_id',
        'value1',
        'value2',
        'value3',
    ],
    ]); ?>

    <?= Html::a('<span class="fa fa-arrow-left"></span> ' . '返回', ['index'], ['class' => 'btn btn-default btn-sm']) ?>
    <?= Html::a('<span class="fa fa-pencil"></span> 操作', ['edit', 'user_id' => $model->user_id],['class' => 'btn btn-info btn-sm']) ?> 
            
    <?php $this->endBlock(); ?>


    
<?php $this->beginBlock('CreditRecords'); ?>
<div style='position: relative'><div style='position:absolute; right: 0px; top: 0px;'>
  <?= Html::a('<span class="fa fa-list"></span> Credit Records列表', ['credit-record/index'], ['class'=>'btn btn-default text-muted btn-xs']) ?>
  <?= Html::a('<span class="fa fa-plus"></span> 新增Credit Record', ['credit-record/create', 'CreditRecord' => ['user_id' => $model->user_id]], ['class'=>'btn btn-success btn-xs']); ?>
</div>
        </div>
        <?php Pjax::begin(['id'=>'pjax-CreditRecords', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-CreditRecords ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>
<?= '<div class="table-responsive">' . \yii\grid\GridView::widget([
    'layout' => '{summary}{pager}<br/>{items}{pager}',
    'dataProvider' => new \yii\data\ActiveDataProvider(['query' => $model->getCreditRecords(), 'pagination' => ['pageSize' => 20, 'pageParam'=>'page-creditrecords']]),
    'pager'        => [
        'class'          => yii\widgets\LinkPager::className(),
        'firstPageLabel' => 'First',
        'lastPageLabel'  => 'Last'
    ],
    'columns' => [[
    'class'      => 'yii\grid\ActionColumn',
    'template'   => '{view} {update}',
    'contentOptions' => ['nowrap'=>'nowrap'],
    'urlCreator' => function ($action, $model, $key, $index) {
        // using the column name as key, not mapping to 'id' like the standard generator
        $params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
        $params[0] = 'credit-record' . '/' . $action;
        return $params;
    },
    'buttons'    => [
        
    ],
    'controller' => 'credit-record'
],
        'id',
        'memo',
        'value1',
        'value2',
        'value3',
        'blance1',
        'blance2',
        'blance3',
]
]) . '</div>' ?>
<?php Pjax::end() ?>
<?php $this->endBlock() ?>

    <?= Tabs::widget(
                 [
                     'id' => 'relation-tabs',
                     'encodeLabels' => false,
                     'items' => [ [
    'label'   => '<b class=""># '.$model->user_id.'</b>',
    'content' => $this->blocks['yiike\credit\models\Credit'],
    'active'  => true,
],[
    'content' => $this->blocks['CreditRecords'],
    'label'   => '<small>余额日志 <span class="badge badge-default">'.count($model->getCreditRecords()->asArray()->all()).'</span></small>',
    'active'  => false,
], ]
                 ]
    );
    ?>        </div>
    </div>
</div>
